package com.atguigu.gmall.mapper;

import com.atguigu.gmall.bean.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author Felix
 * @date 2024/11/11
 * 交易域统计mapper接口
 */

@Mapper
public interface TradeStatsMapper {


    //获取某日各个省份交易额
    /*@Select("select province,sum(amount) order_amount,sum(order_user) order_user,sum(order_count) order_count from dws_province_province_transaction_window " +
            " partition par#{date} group by province")*/
    @Select("select province,sum(amount) orderAmount,sum(order_user) orderUser,sum(order_count) orderCount from dws_province_province_transaction_window " +
            " partition par#{date} group by province")
    List<TradeProvinceTransaction> selectProvinceTransaction(Integer date);

    //各来源交易统计
    @Select("select sc , sum(sum_amount) orderAmount , sum(order_user_sum) orderUser , sum(order_count) orderCount ,\n" +
            "       ( sum(order_user_sum) / sum(uu_ct)) as transformRate\n" +
            "from dws_source_source_transaction_window\n" +
            "partition  par#{date}\n" +
            "group by sc")
    List<SourceTransaction> selectSourceTransaction(Integer date);

    @Select("select sum(order_user) orderUser,sum(order_count) orderCount,sum(amount) orderAmount\n" +
            "from dws_transaction_transaction_statistics_window\n" +
            "partition par#{date}")
    List<TransactionStatistics> selectTransactionStatistics(Integer date);



    @Select("select category , sum(order_user) orderUser,sum(order_count) orderCount,sum(amount) orderAmount\n" +
            "    from dws_category_order_statistics_window\n" +
            "    partition par#{date}\n" +
            "    group by category")
    List<categoryOrderDetail> selectCategoryOrderDetail(Integer date);


    @Select("select subject , sum(order_user) orderUser,sum(order_count) orderCount,sum(amount) orderAmount\n" +
            "    from dws_category_order_statistics_window\n" +
            "    partition par#{date}\n" +
            "    group by subject")
    List<subjectOrderDetail> selectSubjectOrderDetail(Integer date);


    @Select("select course , sum(order_user) orderUser,sum(order_count) orderCount,sum(amount) orderAmount\n" +
            "    from dws_category_order_statistics_window\n" +
            "    partition par#{date}\n" +
            "    group by course")
    List<courseOrderDetail> selectCourseOrderDetail(Integer date);



}